<!DOCTYPE html>
<!-- saved from url=(0046)https://www.runoob.com/java/java-tutorial.html -->
<html version="4">

<head>

    <style type="text/css">
        /*
<div id="__sound-pirate" class="__sound-pirate-at-left">
    <a class="__sound-pirate-to-left"><img src="chrome-extension://naaoeihcbaeganoldlfjnomncgdcdnjf/img/arrowl32.png"></a>
    <a class="__sound-pirate-download" download href=""><img src="chrome-extension://naaoeihcbaeganoldlfjnomncgdcdnjf/img/music32.png"></a>
    <a class="__sound-pirate-to-right"><img src="chrome-extension://naaoeihcbaeganoldlfjnomncgdcdnjf/img/arrowr32.png"></a>
</div>
*/
        #__sound-pirate {
            margin: 0 4px 4px 4px;
            padding: 0;
            border: 0;
            box-sizing: border-box;
            width: 32px;
            position: fixed;
            bottom: 0;
            left: 0;
            z-index: 2147483647;
            cursor: pointer;
            transition: left 1s ease;
        }

        #__sound-pirate.__sound-pirate-at-left:hover .__sound-pirate-to-right {
            display: block;
        }

        #__sound-pirate.__sound-pirate-at-right:hover .__sound-pirate-to-left {
            display: block;
        }

        #__sound-pirate.__sound-pirate-at-right {
            left: calc(100% - 32px - 4px);
        }

        #__sound-pirate * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        #__sound-pirate .__sound-pirate-to-left,
        #__sound-pirate .__sound-pirate-to-right {
            display: none;
            position: absolute;
            width: 14px;
            top: 0;
        }

        #__sound-pirate .__sound-pirate-to-left {
            right: 100%;
        }

        #__sound-pirate .__sound-pirate-to-right {
            left: 100%;
        }

        #__sound-pirate img {
            display: block;
        }

        #__sound-pirate .__sound-pirate-download {
            display: block;
            transform: rotate(0turn);
            transition: transform 1s ease;
        }
    </style>
    <style type="text/css">
        #_copy {
            align-items: center;
            background: #4494d5;
            border-radius: 3px;
            color: #fff;
            cursor: pointer;
            display: flex;
            font-size: 13px;
            height: 30px;
            justify-content: center;
            position: absolute;
            width: 60px;
            z-index: 1000
        }

        #select-tooltip,
        #sfModal,
        .modal-backdrop,
        div[id^=reader-helper] {
            display: none !important
        }

        .modal-open {
            overflow: auto !important
        }

        ._sf_adjust_body {
            padding-right: 0 !important
        }

        .enable_copy_btns_div {
            position: fixed;
            width: 154px;
            left: 10px;
            top: 45%;
            background: #e7f1ff;
            border: 2px solid #4595d5;
            font-weight: 600;
            border-radius: 2px;
            font-family: -apple-system, BlinkMacSystemFont, Segoe UI, PingFang SC, Hiragino Sans GB, Microsoft YaHei, Helvetica Neue, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;
            z-index: 5000
        }

        .enable_copy_btns_logo {
            width: 100%;
            background: #4595d5;
            text-align: center;
            font-size: 12px;
            color: #e7f1ff;
            line-height: 30px;
            height: 30px
        }

        .enable_copy_btns_btn {
            display: block;
            width: 128px;
            height: 28px;
            background: #7f5711;
            border-radius: 4px;
            color: #fff;
            font-size: 12px;
            border: 0;
            outline: 0;
            margin: 8px auto;
            font-weight: 700;
            cursor: pointer;
            opacity: .9
        }

        .enable_copy_btns_btn:hover {
            opacity: .8
        }

        .enable_copy_btns_btn:active {
            opacity: 1
        }
    </style>
</head>

<body style="" inmaintabuse="1">
    <div class="article-body">
		
        <div class="article-intro" id="content">
        
        <h1>Java 教程</h1>

<div class="tutintro">
<img decoding="async" src="//www.runoob.com/wp-content/uploads/2013/12/java.jpg">
<p>Java 是由 Sun Microsystems 公司于 1995 年 5 月推出的高级程序设计语言。</p>

<p>Java 可运行于多个平台，如 Windows, Mac OS 及其他多种 UNIX 版本的系统。</p>
<p>本教程通过简单的实例将让大家更好的了解 Java 编程语言。</p>
<p>移动操作系统 Android 大部分的代码采用 Java 编程语言编程。</p>


</div>
<hr>
<h2>
我的第一个 JAVA 程序</h2>
<p>
以下我们通过一个简单的实例来展示 Java 编程，创建文件 <strong>HelloWorld.java(文件名需与类名一致)</strong>, 代码如下：</p>
<div class="example"> 
<h2 class="example">实例</h2> 
<div class="example_code">

<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> HelloWorld <span style="color: #009900;">{</span><br>
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">(</span><span style="color: #003399;">String</span><span style="color: #009900;">[</span><span style="color: #009900;">]</span> args<span style="color: #009900;">)</span> <span style="color: #009900;">{</span><br>
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">(</span><span style="color: #0000ff;">"Hello World"</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span><br>
&nbsp; &nbsp; <span style="color: #009900;">}</span><br>
<span style="color: #009900;">}</span><br>

<button class="copy-code-button" type="button" data-clipboard-text="public class HelloWorld {
&nbsp; &nbsp; public static void main(String[] args) {
&nbsp; &nbsp; &nbsp; &nbsp; System.out.println(&quot;Hello World&quot;);
&nbsp; &nbsp; }
}"></button></div><br>
</div>


<blockquote><p><strong>注：</strong><span class="marked">String args[]</span> 与 <span class="marked">String[] args</span> 都可以执行，但推荐使用 <span class="marked">String[] args</span>，这样可以避免歧义和误读。</p></blockquote>


<p>运行以上实例，输出结果如下：</p>
<pre class="prettyprint prettyprinted" style=""><span class="pln">$ javac </span><span class="typ">HelloWorld</span><span class="pun">.</span><span class="pln">java
$ java </span><span class="typ">HelloWorld</span><span class="pln">
</span><span class="typ">Hello</span><span class="pln"> </span><span class="typ">World</span><button class="copy-code-button" type="button" data-clipboard-text="$ javac HelloWorld.java
$ java HelloWorld
Hello World
"></button></pre>
<h3>执行命令解析：</h3>
<p>以上我们使用了两个命令 <strong>javac</strong> 和 <strong>java</strong>。</p>
<p><strong>javac</strong> 后面跟着的是java文件的文件名，例如 HelloWorld.java。
该命令用于将 java 源文件编译为 class 字节码文件，如： <strong>javac HelloWorld.java</strong>。</p>

<p>
运行javac命令后，如果成功编译没有错误的话，会出现一个 HelloWorld.class 的文件。</p>
<p>
<strong>java</strong> 后面跟着的是java文件中的类名,例如 HelloWorld 就是类名，如: java HelloWorld。</p>

<p><strong>注意</strong>：java命令后面不要加.class。</p>

        <!-- 其他扩展 -->
                    
        </div>
        
    </div>
</body>

</html>